<!-- 编辑简历页面 -->
<template>
    <div>
        <!-- 头部 -->
        <reception-header/>

        <div class="user">
            <div class="da-wrapper">
                <div class="da-content">
                    <div class="container">
                        <div class="zaixian">
                            <div class="title">
                                <span class="title-style">在线简历</span>
                            </div>
                        </div>
                        <div class="enclosure">
                            <el-upload
                                class="upload-demo"
                                action=""
                                :http-request="uploadEnclosure"
                                accept=".doc,.docx"
                                :before-upload="beforeEnclosure"
                                :file-list="fileList"
                                :limit="1"
                            >
                                <el-button type="primary">上传简历</el-button>
                                <div slot="tip" class="el-upload__tip">可以不用填写在线简历</div>
                            </el-upload>
                        </div>
                        <!-- 表单 -->
                        <div>
                            <div class="personalInfo">个人信息</div>
                            <!-- 个人信息表单 -->
                            <div>
                                <el-form :model="personalInfo" :rules="personalInfoRules" ref="personalInfo" label-width="100px" class="personalInfoForm">
                                    <el-form-item label="上传简历头像" prop="resumeAvatar">
                                        <el-upload
                                            class="avatar-uploader"
                                            action=""
                                            :limit="1"
                                            :show-file-list="false"
                                            :http-request="uploadImage"
                                            :on-success="handleAvatarSuccess"
                                            :before-upload="beforeAvatarUpload">
                                        <img v-if="personalInfo.resumeAvatar" :src="personalInfo.resumeAvatar" class="avatar" title="点击更换头像">
                                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                        </el-upload>
                                    </el-form-item>
                                    <el-form-item label="姓名" prop="name">
                                        <el-input v-model="personalInfo.name" clearable placeholder="请输入姓名"></el-input>
                                    </el-form-item>
                                    <el-form-item label="性别" prop="sex">
                                        <el-select v-model="personalInfo.sex" placeholder="请选择性别">
                                            <el-option label="男" value="1"></el-option>
                                            <el-option label="女" value="0"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="当前身份" prop="currentIdentity">
                                        <el-select v-model="personalInfo.currentIdentity" placeholder="请选择身份">
                                            <el-option label="职场人" value="职场人"></el-option>
                                            <el-option label="学生" value="学生"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="出生年月" prop="birth">
                                         <el-date-picker
                                            v-model="personalInfo.birth"
                                            type="date"
                                            placeholder="选择日期">
                                        </el-date-picker>
                                    </el-form-item>
                                    <el-form-item label="户口所在地" prop="hukou">
                                        <el-input v-model="personalInfo.hukou" clearable placeholder="请输入户口所在地(例如：云南昆明...)"></el-input>
                                    </el-form-item>
                                    <el-form-item label="现居住城市" prop="city">
                                        <el-input v-model="personalInfo.city" clearable placeholder="请输入现居住城市"></el-input>
                                    </el-form-item>
                                    <el-form-item label="政治面貌" prop="outlook">
                                         <el-select v-model="personalInfo.outlook" placeholder="请选择政治面貌">
                                            <el-option label="中共党员（含预备党员）" value="中共党员（含预备党员）"></el-option>
                                            <el-option label="民主党派" value="民主党派"></el-option>
                                            <el-option label="无党派人士" value="无党派人士"></el-option>
                                            <el-option label="共青团员" value="共青团员"></el-option>
                                            <el-option label="群众" value="群众"></el-option>
                                        </el-select>
                                    </el-form-item>
                                     <el-form-item label="联系方式" prop="phone">
                                        <el-input v-model="personalInfo.phone" clearable placeholder="请输入联系方式"></el-input>
                                    </el-form-item>
                                     <el-form-item label="电子邮箱" prop="email">
                                        <el-input v-model="personalInfo.email" clearable placeholder="请输入电子邮箱"></el-input>
                                    </el-form-item>
                                </el-form>
                            </div>
                            <!-- 求职状态 -->
                            <div class="job-state-container">
                                <span class="job-state">求职状态&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="jobStateForm" :rules="jobStateFormRules" ref="jobStateForm" label-width="100px" class="personalInfoForm">
                                         <el-form-item label="求职状态" prop="jobState">
                                            <el-select v-model="jobStateForm.jobState" placeholder="请选择求职状态">
                                                <el-option label="离校-正在找工作" value="离校-正在找工作"></el-option>
                                                <el-option label="在校-正在找工作" value="在校-正在找工作"></el-option>
                                                <el-option label="在校-看看机会" value="在校-看看机会"></el-option>
                                                <el-option label="在校-暂不找工作" value="在校-暂不找工作"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-form>
                                </div>
                            </div>
                            <!-- 求职意向 -->
                            <div class="job-state-container">
                                <span class="job-state">求职意向&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="jobExceptForm" :rules="jobExceptFormRules" ref="jobExceptForm" label-width="150px" class="personalInfoForm">
                                        <el-form-item label="期望职位" prop="expectWork">
                                            <el-input v-model="jobExceptForm.expectWork" clearable placeholder="请输入期望职位"></el-input>
                                        </el-form-item>
                                        <el-form-item label="期望行业" prop="expectIndustry">
                                            <el-input v-model="jobExceptForm.expectIndustry" clearable placeholder="请输入期望行业"></el-input>
                                        </el-form-item>
                                        <el-form-item label="期望工作地点" prop="expectWorkAddress">
                                            <el-input v-model="jobExceptForm.expectWorkAddress" clearable placeholder="请输入期望工作地点"></el-input>
                                        </el-form-item>
                                        <el-form-item label="期望薪资" prop="expectSalary">
                                            <el-input v-model="jobExceptForm.expectSalary" clearable placeholder="请输入期望薪资"></el-input>
                                        </el-form-item>
                                    </el-form>
                                </div>
                            </div>
                            <!-- 教育经历 -->
                            <div class="job-state-container">
                                <span class="job-state">教育经历&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="edu_experienceForm" :rules="edu_experienceFormRules" ref="edu_experienceForm" label-width="100px" class="personalInfoForm">
                                        <el-form-item label="学历" prop="highest_education">
                                            <el-select v-model="edu_experienceForm.highest_education" placeholder="请选择学历">
                                                <el-option label="初中及以下" value="初中及以下"></el-option>
                                                <el-option label="高中" value="高中"></el-option>
                                                <el-option label="中专/中技" value="中专/中技"></el-option>
                                                <el-option label="大专" value="大专"></el-option>
                                                <el-option label="本科" value="本科"></el-option>
                                                <el-option label="硕士" value="硕士"></el-option>
                                                <el-option label="MBA/EMBA" value="MBA/EMBA"></el-option>
                                                <el-option label="博士" value="博士"></el-option>
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item label="学校" prop="school">
                                            <el-input v-model="edu_experienceForm.school" clearable placeholder="请输入学校"></el-input>
                                        </el-form-item>
                                        <el-form-item label="专业" prop="major">
                                            <el-input v-model="edu_experienceForm.major" clearable placeholder="请输入专业"></el-input>
                                        </el-form-item>
                                    </el-form>
                                </div>
                            </div>
                            <!-- 工作 / 实习经历 -->
                            <div class="job-state-container">
                                <span class="job-state">工作 / 实习经历&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="shixiForm" :rules="shixiFormRules" ref="shixiForm" label-width="200px" class="personalInfoForm">
                                        <el-form-item label="公司名称" prop="companyName">
                                            <el-input v-model="shixiForm.companyName" clearable placeholder="请输入公司名称（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="公司所属行业" prop="companyType">
                                            <el-input v-model="shixiForm.companyType" clearable placeholder="请输入所属行业（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="实习或工作时岗位" prop="companyPosition">
                                            <el-input v-model="shixiForm.companyPosition" clearable placeholder="请输入实习或工作时岗位（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="实习或工作的薪资" prop="internshipSalary">
                                            <el-input v-model="shixiForm.internshipSalary" clearable placeholder="请输入实习或工作的薪资（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="工作描述" prop="internshipDescription">
                                            <el-input v-model="shixiForm.internshipDescription" type="textarea" :autosize="{minRows:3}" clearable placeholder="请输入工作描述（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                    </el-form>
                                </div>
                            </div>
                             <!-- 项目经历 -->
                            <div class="job-state-container">
                                <span class="job-state">项目经历&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="projectExperienceForm" :rules="projectExperienceFormRules" ref="projectExperienceForm" label-width="200px" class="personalInfoForm">
                                        <el-form-item label="项目名称" prop="projectName">
                                            <el-input v-model="projectExperienceForm.projectName" clearable placeholder="请输入项目名称（无任何经历请填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="项目描述" prop="projectDescription">
                                            <el-input v-model="projectExperienceForm.projectDescription" type="textarea" :autosize="{minRows:3}" clearable placeholder="请输入项目描述（无任何经历请填“无”）"></el-input>
                                        </el-form-item>                              
                                    </el-form>
                                </div>
                            </div>
                              <!-- 其他 -->
                            <div class="job-state-container">
                                <span class="job-state">其他&nbsp;</span>
                                <el-tag size="mini" effect="dark" type="danger" class="tag">必填</el-tag>
                                <div>
                                    <el-form :model="otherForm" :rules="otherFormRules" ref="otherForm" label-width="200px" class="personalInfoForm">
                                        <el-form-item label="英语等级" prop="englishLevel">
                                            <el-input v-model="otherForm.englishLevel" clearable placeholder="没有请填“无”；有则填等级名称 + 成绩"></el-input>
                                        </el-form-item>
                                        <el-form-item label="有哪些技能" prop="skill">
                                            <el-input v-model="otherForm.skill" type="textarea" :autosize="{minRows:3}" clearable placeholder="请填写技能（没有则填“无”）"></el-input>
                                        </el-form-item>
                                        <el-form-item label="有哪些证书" prop="certificate">
                                            <el-input v-model="otherForm.certificate" type="textarea" :autosize="{minRows:3}" clearable placeholder="请填写证书（没有则填“无”）"></el-input>
                                        </el-form-item> 
                                        <el-form-item label="个人优势" prop="selfAdvantang">
                                            <el-input v-model="otherForm.selfAdvantang" type="textarea" :autosize="{minRows:3}" clearable placeholder="请填写个人优势（没有则填“无”）"></el-input>
                                        </el-form-item> 
                                        <el-form-item label="自我评价" prop="selfEvaluate">
                                            <el-input v-model="otherForm.selfEvaluate" type="textarea" :autosize="{minRows:3}" clearable placeholder="请填写自我评价（没有则填“无”）"></el-input>
                                        </el-form-item>                                
                                    </el-form>
                                </div>
                            </div>
                            <el-button type="primary" @click="submitForm('personalInfo')">保存简历</el-button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 底部 -->
        <the-footer/>
    </div>
</template>

<script>
import ReceptionHeader from '../../components/ReceptionHeader.vue';
import TheFooter from '../../components/The-Footer.vue';
import { client } from '../../utils/alioss';
import { saveResumeUrl } from '../../api/userManage/index';
import { saveResume,getCompanyOrUserAllInfo,queryLoginUserResume } from '../../api/personalApi';
import { getStore } from '../../storage/storage';
export default {
    components: { ReceptionHeader, TheFooter },
    data () {
        var checkPhone = (rule, value, callback) => {
            const phoneReg = /^1[3|4|5|6|7|8|9][0-9]{9}$/
            setTimeout(() => {
                if (!Number.isInteger(+value)) {
                    callback(new Error('请输入数字'))
                } else {
                    if (phoneReg.test(value)) {
                        callback();                       
                    } else {
                        callback(new Error('电话号码格式不正确'))
                    }
                }
            }, 100)
        }
        var checkEmail = (rule, value, callback) => {
            const mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/       
            setTimeout(() => {
                if (mailReg.test(value)) {
                    callback()
                } else {
                    callback(new Error('请输入正确的邮箱格式'))
                }   
            }, 100)
        }
        return {
            fileOraginName: '', // 简历的原始文件名
            fileType: '', // 上传简历文件的类型
            fileList: [], // 上传简历文件列表的类型
            personalInfo:{  // 个人信息表单
                name: '', // 姓名
                sex: '', // 性别
                currentIdentity: '', // 当前身份
                resumeAvatar: '', // 简历头像的地址
                birth: '', // 出生年月
                hukou: '',  // 户口所在地
                city: '',  // 城市
                outlook: '', // 政治面貌
                phone: '', // 联系方式
                email: '', // 电子邮箱
            },
            jobStateForm: { // 求职状态表单
                jobState: '', // 求职状态
            },
            jobExceptForm: { // 求职意向表单
                expectWork: '', // 期望职位
                expectIndustry: '', // 期望行业
                expectWorkAddress: '', // 期望工作地点
                expectSalary: '', // 期望薪资
            },
            edu_experienceForm: {  // 教育经历表单
                highest_education: '', // 最高学历
                school: '', // 学校
                major: '', // 专业
            },
            shixiForm:{  // 实习或工作经历的表单
                companyName: '', // 公司名称
                companyType: '', // 公司类型（所属行业）
                companyPosition: '', // 负责的岗位
                internshipDescription: '', // 工作描述
                internshipSalary: '', // 薪资
            },
            projectExperienceForm:{  // 项目经历表单
                projectName: '', // 项目名称
                projectDescription: '', // 项目描述
            },
            otherForm:{
                englishLevel: '', // 英语等级
                skill: '', // 技能
                certificate: '', // 证书
                selfAdvantang: '', // 个人优势
                selfEvaluate: '', // 自我评价
            },
            otherFormRules:{
                englishLevel: [
                    { required: true, message: '请填写英语等级，没有请填“无”；有则填等级名称 + 成绩', trigger: 'blur' },
                ],
                skill: [
                    { required: true, message: '请填写技能（没有则填“无”）', trigger: 'blur' },
                ],
                certificate: [
                    { required: true, message: '请填写证书（没有则填“无”）', trigger: 'blur' },
                ],
                selfAdvantang: [
                    { required: true, message: '请填写个人优势（没有则填“无”）', trigger: 'blur' },
                ],
                selfEvaluate: [
                    { required: true, message: '请填写自我评价（没有则填“无”）', trigger: 'blur' },
                ],
            },
            projectExperienceFormRules:{
                projectName: [
                    { required: true, message: '请输入项目名称', trigger: 'blur' },
                ],
                projectDescription: [
                    { required: true, message: '请输入项目描述', trigger: 'blur' },
                ],
            },
            shixiFormRules:{
                companyName: [
                    { required: true, message: '请输入公司名称', trigger: 'blur' },
                ],
                companyType: [
                    { required: true, message: '请输入公司类型（所属行业）', trigger: 'blur' },
                ],
                companyPosition: [
                    { required: true, message: '请输入负责的岗位', trigger: 'blur' },
                ],
                internshipDescription: [
                    { required: true, message: '请输入工作描述', trigger: 'blur' },
                ],
                internshipSalary: [
                    { required: true, message: '请输入薪资', trigger: 'blur' },
                ],
            },
            edu_experienceFormRules:{  // 教育经历规则
                highest_education: [
                    { required: true, message: '请选择学历', trigger: 'change' },
                ],
                school: [
                    { required: true, message: '请输入学校', trigger: 'blur' },
                ],
                major: [
                    { required: true, message: '请输入专业', trigger: 'blur' },
                ],
            },
            jobExceptFormRules: {  // 求职意向规则
                expectWork: [
                    { required: true, message: '请输入期望工作', trigger: 'blur' },
                ],
                expectIndustry: [
                    { required: true, message: '请输入期望行业', trigger: 'blur' },
                ],
                expectWorkAddress: [
                    { required: true, message: '请输入期望工作地点', trigger: 'blur' },
                ],
                expectSalary: [
                    { required: true, message: '请输入期望薪资', trigger: 'blur' },
                ],
            },
            jobStateFormRules: {  // 求职状态规则
                jobState: [
                    { required: true, message: '请选择求职状态', trigger: 'change' },
                ],
            },
            personalInfoRules:{  // 个人信息规则
                name:[
                    { required: true, message: '请输入姓名', trigger: 'blur' },
                ],
                sex:[
                    { required: true, message: '请输入选择性别', trigger: 'change' },
                ],
                currentIdentity:[
                    { required: true, message: '请输入选择当前身份', trigger: 'change' },
                ],
                birth:[
                    { required: true, message: '请输入选择出生年月', trigger: 'change' },
                ],
                hukou:[
                    { required: true, message: '请输入户口所在地', trigger: 'blur' },
                ],
                city:[
                    { required: true, message: '请输入现居住城市', trigger: 'blur' },
                ],
                outlook:[
                    { required: true, message: '请选择政治面貌', trigger: 'change' },
                ],
                email:[
                    { required: true, message: '请输入联系方式', trigger: 'blur' },
                    { validator: checkEmail, trigger: ['blur','change'] },
                ],
                phone:[
                    { required: true, message: '请选择电子邮箱', trigger: 'blur' },
                    { validator: checkPhone, trigger: ['blur','change'] },
                ],
            },
        }
    },
    created(){
        // 查询当前登陆人身份信息
        this.getLoginUserInfoFunc();

        // 查询当前登陆人简历信息
        this.queryLoginUserResumeFunc();
    },
    methods:{

        // 查询当前登陆人身份信息
        getLoginUserInfoFunc(){
            const params = {
                account: getStore("account"),
            }
            getCompanyOrUserAllInfo(params).then(res=>{
                // console.log(res);
                this.personalInfo.resumeAvatar = res.data.data.avatar ? res.data.data.avatar : '';
                this.personalInfo.name = res.data.data.userName;
                this.personalInfo.sex = res.data.data.userSex ? res.data.data.userSex : '';
                this.personalInfo.phone = res.data.data.userPhone;
                this.personalInfo.email = res.data.data.userEmail;
            })
        },

        // 查询当前登陆人简历信息
        queryLoginUserResumeFunc(){
            const params = {
                account: getStore("account"),
            }
            queryLoginUserResume(params).then(res=>{
                console.log(res);
                this.personalInfo.currentIdentity = res.data.data[0].currentIdentity;
                this.personalInfo.birth = res.data.data[0].birth;
                this.personalInfo.hukou = res.data.data[0].hukou;
                this.personalInfo.outlook = res.data.data[0].outlook;
                this.personalInfo.city = res.data.data[0].city;
                this.jobStateForm.jobState = res.data.data[0].huntjobState;
                this.jobExceptForm.expectWork = res.data.data[0].expectWork;
                this.jobExceptForm.expectIndustry = res.data.data[0].expectIndustry;
                this.jobExceptForm.expectWorkAddress = res.data.data[0].expectCity;
                this.jobExceptForm.expectSalary = res.data.data[0].expectSalary;
                this.edu_experienceForm.highest_education = res.data.data[0].highestEducation;
                this.edu_experienceForm.school = res.data.data[0].school;
                this.edu_experienceForm.major = res.data.data[0].major;
                this.shixiForm.companyName = res.data.data[0].companyName;
                this.shixiForm.companyType = res.data.data[0].companyType;
                this.shixiForm.companyPosition = res.data.data[0].companyPosition;
                this.shixiForm.internshipDescription = res.data.data[0].internshipWorkDescription;
                this.shixiForm.internshipSalary = res.data.data[0].internshipWorkSalary;
                this.projectExperienceForm.projectName = res.data.data[0].projectName;
                this.projectExperienceForm.projectDescription = res.data.data[0].projectDescription;
                this.otherForm.englishLevel = res.data.data[0].englishLevel;
                this.otherForm.skill = res.data.data[0].skillDescription;
                this.otherForm.certificate = res.data.data[0].certificate;
                this.otherForm.selfAdvantang = res.data.data[0].personalAdvantange;
                this.otherForm.selfEvaluate = res.data.data[0].selfEvaluation;
            })
        },

        // 上传图片
        uploadImage(file){
            // 定义唯一文件名
            var fileName = 'company' + `${Date.parse(new Date())}` + '.jpg';
            client().multipartUpload(fileName, file.file).then(res=>{
                this.$message.success('上传成功！');
                this.personalInfo.resumeAvatar = 'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/' + fileName;
            });
        },
        handleAvatarSuccess(res, file) {
            this.personalInfo.resumeAvatar = URL.createObjectURL(file.raw);
        },
        beforeAvatarUpload(file) {
            const isJPG = (file.type === 'image/jpeg' || file.type === 'image/png');
            const isLt5M = file.size / 1024 / 1024 < 5;

            if (!isJPG) {
                this.$message.error('上传头像图片只能是 jpg或png格式 格式!');
            }
            if (!isLt5M) {
                this.$message.error('上传头像图片大小不能超过 5MB!');
            }
            return isJPG && isLt5M;
        },

        // 附件简历上传之前
        beforeEnclosure(file){
            // 截取上传文件的后缀名
            let fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
            this.fileType = '.' + fileType;
            this.fileOraginName = file.name.substring(0,file.name.lastIndexOf("."));
            // 判断文件名的类型
            if (fileType !== "doc" && fileType !== "docx" && fileType !== "pdf") {
                this.$message.error('简历上传的格式只能是 doc或docx或pdf 格式!');
            }else{
                return true
            }
            return false;
        },

        // 保存简历
        submitForm(formName){
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    // 保存简历的参数
                    if (this.personalInfo.sex === '男') {
                        this.personalInfo.sex = 1;
                    }else if (this.personalInfo.sex === '女') {
                        this.personalInfo.sex = 0;
                    }
                    const params = {
                        name: this.personalInfo.name,
                        sex: this.personalInfo.sex,
                        currentIdentity: this.personalInfo.currentIdentity,
                        resumeAvatar: this.personalInfo.resumeAvatar,
                        birth: this.personalInfo.birth,
                        hukou: this.personalInfo.hukou,
                        city: this.personalInfo.city,
                        outlook: this.personalInfo.outlook,
                        phone: this.personalInfo.phone,
                        email: this.personalInfo.email,
                        jobState: this.jobStateForm.jobState,
                        expectWork: this.jobExceptForm.expectWork,
                        expectIndustry: this.jobExceptForm.expectIndustry,
                        expectWorkAddress: this.jobExceptForm.expectWorkAddress,
                        expectSalary: this.jobExceptForm.expectSalary,
                        highestEducation: this.edu_experienceForm.highest_education,
                        school: this.edu_experienceForm.school,
                        major: this.edu_experienceForm.major,
                        companyName: this.shixiForm.companyName,
                        companyType: this.shixiForm.companyType,
                        companyPosition: this.shixiForm.companyPosition,
                        internshipSalary: this.shixiForm.internshipSalary,
                        internshipDescription: this.shixiForm.internshipDescription,
                        projectName: this.projectExperienceForm.projectName,
                        projectDescription: this.projectExperienceForm.projectDescription,
                        englishLevel: this.otherForm.englishLevel,
                        skill: this.otherForm.skill,
                        certificate: this.otherForm.certificate,
                        selfAdvantang: this.otherForm.selfAdvantang,
                        selfEvaluate: this.otherForm.selfEvaluate,
                        account: getStore("account"),
                    };
                    // 保存简历
                    const _this = this;
                            
                    saveResume(params).then(res=>{
                        if (res.data.code === 10000) {
                            _this.$message({
                                message: res.data.message,
                                type: 'success',
                                duration: 800,
                            })
                            setTimeout(() => {
                                // 跳转到我的简历页面
                                this.$router.push("/reception/myResumePage");
                            }, 800);
                        } else {
                            _this.$message({
                                message: res.data.message,
                                type: 'error',
                                duration: 800,
                            })
                        }     
                    })
                } else {
                    this.$message({
                        message: '请填写必填信息',
                        type: 'error',
                        duration: 500,
                    })
                    return false;
                }
            });
        },

        // 上传附件简历
        uploadEnclosure(file){
            // 定义唯一文件名
            var fileName = 'resume/' + `${Date.parse(new Date())}` + this.fileOraginName + this.fileType;
            client().multipartUpload(fileName, file.file).then(res=>{
                this.$message.success('上传成功！');
                var resumeUrl = 'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/' + fileName;

                // 将简历url保存到数据库
                const params = {
                    account: getStore("account"),
                    resumeUrl,
                }
                saveResumeUrl(params).then(()=>{});

            });
        }

    },
}
</script>

<style scoped>
@import '../../assets/css/reception/editMyResume.css';
</style>
